VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Flags"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private Type flag
    nme As String
    unme As String
    value As String
End Type

Dim flags() As flag

Private Sub Class_Initialize()
ReDim flags(0) 'Malloc ourselves a nice flag
End Sub

Public Sub Parseflags(ByVal inp As String)
Dim nflags As Long
Dim k As Long
Dim nx As Long
Dim cres As String
Dim flagsep As Long
Dim arg As String
Dim flg As String

nflags = UBound(flags) + 1

k = 0
Do
k = InStr(k + 1, inp, "-")
nx = InStr(k + 1, inp, "-") 'Grab the text between flags
If k = 0 Then Exit Do 'No more flags

If nx = 0 Then nx = Len(inp) + 1
cres = Trim(Mid(inp, k + 1, nx - k - 1))

flgsep = InStr(1, cres, " ") 'Find the seperator between the flag and its argument.
If flgsep = 0 Then flgsep = Len(cres)

flg = Mid(cres, 1, flgsep) 'The flag
If flgsep > 0 Then
    arg = Mid(cres, flgsep)
Else
    arg = ""
End If

ReDim Preserve flags(nflags)
flags(nflags).nme = flg
flags(nflags).unme = Trim(UCase(flg))
flags(nflags).value = arg
nflags = nflags + 1
Loop
End Sub

Public Function Hasflag(flg) As Boolean
Dim inp As String
inp = UCase(Trim(flg))
Dim x As Long

For x = 1 To UBound(flags)
If flags(x).unme = inp Then
    Hasflag = True
    Exit Function
End If
Next

Hasflag = False
End Function

Public Function Getflag(flg) As String
Dim inp As String
inp = UCase(Trim(flg))
Dim x As Long

For x = 1 To UBound(flags)
If flags(x).unme = inp Then
    Getflag = flags(x).value
    Exit Function
End If
Next
End Function
Private Sub Class_Terminate()
Erase flags 'Just clearing the trash...
End Sub
